/*
 * PrincipalWindow.java
 *
 * Created on __DATE__, __TIME__
 */

package gui;

import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Desktop;
import java.awt.FlowLayout;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.print.Book;
import java.awt.print.PageFormat;
import java.awt.print.Printable;
import java.awt.print.PrinterException;
import java.awt.print.PrinterJob;
import java.io.IOException;
import java.text.DecimalFormat;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Locale;

import javax.swing.BorderFactory;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.border.Border;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;

import core.Calculator;
import core.Core;
import core.DateCalendar;
import core.UserEntry;

/**
 * 
 * @author __USER__
 */
public class PrincipalWindow extends javax.swing.JFrame {

	private Core core = null;
	private DefaultTableModel model = null;
	private DateCalendar date = null;
	private List<UserEntry> curEntries = null;

	public DefaultTableModel getModel() {
		return model;
	}

	public javax.swing.JTable getjTable1() {
		return jTable1;
	}

	/** Creates new form PrincipalWindow */
	public PrincipalWindow() {

		core = Core.get();
		initComponents();
		configure();
		jButton2.setToolTipText("Search");
		jButton3.setToolTipText("Print");
		jButton4.setToolTipText("Chart");
		jButton5.setToolTipText("Calc");
		jButton6.setToolTipText("Help");
		jButton7.setToolTipText("Add");
		jButton8.setToolTipText("Edit");
		jButton9.setToolTipText("Delete");
		importButton.setToolTipText("Import/Export");

		jTable1.setColumnSelectionAllowed(false);
		jTable1.getTableHeader().setReorderingAllowed(false);
	}

	public javax.swing.JLabel getMonthLabel() {
		return monthLabel;
	}

	public void setMonthLabel(javax.swing.JLabel monthLabel) {
		this.monthLabel = monthLabel;
	}

	public void initDatePanel() {
		Date d = new Date();
		date = new DateCalendar(d.getMonth(), d.getYear() + 1900);
		monthLabel.setText(date.getDate().get(0) + " " + date.getDate().get(1));
	}

	public void refreshTable() {
		List<UserEntry> l = core.getEntriesFor(date.getMonth(), date.getYear());
		initTable(l);
	}

	public void initTable(List<UserEntry> entries) {
		curEntries = entries;
		Iterator<UserEntry> i = entries.iterator();

		model = (DefaultTableModel) jTable1.getModel();
		model.setNumRows(0);
		model.setColumnCount(0);
		// jTable1.setBorder(BorderFactory.createLineBorder(new Color(0,0,0),
		// 1));

		model.addColumn("Date");
		model.addColumn("Category");
		model.addColumn("Comment");
		model.addColumn("Debit");
		model.addColumn("Credit");
		jTable1.getColumnModel().getColumn(3)
				.setCellRenderer(new CellRendererRed());
		jTable1.getColumnModel().getColumn(4)
				.setCellRenderer(new CellRendererGreen());

		DecimalFormat df = new DecimalFormat("0.00\u20ac");
		while (i.hasNext()) {
			UserEntry current = (UserEntry) i.next();
			SimpleDateFormat format = new SimpleDateFormat("dd/MM/yyyy");
			String catName = core.getCategoryName(current.getCategoryId());
			if (catName == null)
				catName = new String("None");
			if (!current.isCredit()) {
				model.addRow(new Object[] { format.format(current.getDate()),
						catName, current.getComment(), null,
						df.format(current.getValue()) });
			} else {
				model.addRow(new Object[] { format.format(current.getDate()),
						catName, current.getComment(),
						df.format(Math.abs(current.getValue())), null });
			}
		}
		for (int j = 0; j < 32; ++j)
			model.addRow(new Object[] {});
		SetBalances();
	}

	private void SetBalances() {
		System.out.println("SetBalances");
		NewBalanceLabel1.setText("Debit of the month");
		PreviousBalanceLabel1.setText("Credit of the month");
		this.jTabbedPane3.setTitleAt(0, "Balance");
		this.jTabbedPane3.setTitleAt(1, "Month");
		DecimalFormat df = new DecimalFormat("0.00\u20ac");

		date.getPrevious();
		PreviousBalanceValue.setText(df.format(core.getCalculator().getBalance(
				Calculator.endOf(date.getYear(), date.getMonth()))));
		date.getNext();
		NewBalanceValue.setText(df.format(core.getCalculator().getBalance(
				Calculator.endOf(date.getYear(), date.getMonth()))));

		NewBalanceValue1.setText(df.format(core.getCalculator().getBalanceNeg(
				Calculator.beginOf(date.getYear(), date.getMonth()),
				Calculator.endOf(date.getYear(), date.getMonth()))));
		PreviousBalanceValue1.setText(df.format(core.getCalculator()
				.getBalancePos(
						Calculator.beginOf(date.getYear(), date.getMonth()),
						Calculator.endOf(date.getYear(), date.getMonth()))));

		NewBalanceValue2.setText(df
				.format(core.getCalculator().getBalanceNeg()));
		PreviousBalanceValue2.setText(df.format(core.getCalculator()
				.getBalancePos()));
	}

	public void configure() {
		try {
			// UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
			// UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
			UIManager
					.setLookAndFeel("com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel");
			// UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
			// UIManager.setLookAndFeel("com.sun.java.swing.plaf.windows.WindowsClassicLookAndFeel");
		} catch (Exception e) {
			e.printStackTrace();
		}
		SwingUtilities.updateComponentTreeUI(this);

		jEditorPane1.setText(core.getNote());
		initDatePanel();
		List<UserEntry> l = core.getEntriesFor(date.getMonth(), date.getYear());
		jTable1.addMouseListener(new MouseListener() {
			public void mouseClicked(MouseEvent e) {
			}

			@Override
			public void mouseEntered(MouseEvent e) {
			}

			@Override
			public void mouseExited(MouseEvent e) {
			}

			@Override
			public void mousePressed(MouseEvent e) {
				System.out.println("T1");
				if (e.getClickCount() == 2) {
					System.out.println("T2");
					callEntryWindowsModify(e);
					e.consume();
				}
			}

			@Override
			public void mouseReleased(MouseEvent e) {
			}
		});
		initTable(l);
	}

	void setDate(int month, int year) {
		date.setDate(month, year);
		monthLabel.setText(date.getDate().get(0) + year);
		refreshTable();
	}

	//GEN-BEGIN:initComponents
	// <editor-fold defaultstate="collapsed" desc="Generated Code">
	private void initComponents() {

		BackgroundPanel = new javax.swing.JPanel();
		jToolBar1 = new javax.swing.JToolBar();
		importButton = new javax.swing.JButton();
		jButton2 = new javax.swing.JButton();
		jButton3 = new javax.swing.JButton();
		jButton4 = new javax.swing.JButton();
		jButton5 = new javax.swing.JButton();
		jButton6 = new javax.swing.JButton();
		LeftPanel = new javax.swing.JPanel();
		jTabbedPane2 = new javax.swing.JTabbedPane();
		jScrollPane2 = new javax.swing.JScrollPane();
		jEditorPane1 = new javax.swing.JEditorPane();
		jTabbedPane3 = new javax.swing.JTabbedPane();
		BankBalancePanel = new javax.swing.JPanel();
		lightLabel = new javax.swing.JLabel();
		PreviousBalanceLabel = new javax.swing.JLabel();
		PreviousBalanceValue = new javax.swing.JLabel();
		NewBalanceLabel = new javax.swing.JLabel();
		NewBalanceValue = new javax.swing.JLabel();
		ClearedPanel = new javax.swing.JPanel();
		lightLabel1 = new javax.swing.JLabel();
		PreviousBalanceLabel1 = new javax.swing.JLabel();
		PreviousBalanceValue1 = new javax.swing.JLabel();
		NewBalanceLabel1 = new javax.swing.JLabel();
		NewBalanceValue1 = new javax.swing.JLabel();
		DetailsPanel = new javax.swing.JPanel();
		lightLabel2 = new javax.swing.JLabel();
		PreviousBalanceLabel2 = new javax.swing.JLabel();
		PreviousBalanceValue2 = new javax.swing.JLabel();
		NewBalanceLabel2 = new javax.swing.JLabel();
		NewBalanceValue2 = new javax.swing.JLabel();
		ChartLabel = new javax.swing.JLabel();
		jTabbedPane1 = new javax.swing.JTabbedPane();
		jPanel1 = new javax.swing.JPanel();
		jButton7 = new javax.swing.JButton();
		jButton8 = new javax.swing.JButton();
		jButton9 = new javax.swing.JButton();
		jLabel1 = new javax.swing.JLabel();
		jLabel2 = new javax.swing.JLabel();
		jLabel3 = new javax.swing.JLabel();
		DatePanel = new javax.swing.JPanel();
		leftArrowLabel = new javax.swing.JLabel();
		monthLabel = new javax.swing.JLabel();
		rightArrowLabel = new javax.swing.JLabel();
		jLabel4 = new javax.swing.JLabel();
		jScrollPane1 = new javax.swing.JScrollPane();
		jTable1 = new javax.swing.JTable();
		jMenuBar1 = new javax.swing.JMenuBar();
		jMenu1 = new javax.swing.JMenu();
		jMenuItem1 = new javax.swing.JMenuItem();
		jMenuItem2 = new javax.swing.JMenuItem();
		jMenuItem3 = new javax.swing.JMenuItem();
		jMenuItem4 = new javax.swing.JMenuItem();
		jMenu2 = new javax.swing.JMenu();
		jMenuItem5 = new javax.swing.JMenuItem();
		jMenuItem6 = new javax.swing.JMenuItem();
		jMenuItem7 = new javax.swing.JMenuItem();
		jMenu5 = new javax.swing.JMenu();
		jMenuItem8 = new javax.swing.JMenuItem();
		jMenu6 = new javax.swing.JMenu();
		jMenuItem9 = new javax.swing.JMenuItem();
		jMenu7 = new javax.swing.JMenu();
		jMenuItem10 = new javax.swing.JMenuItem();
		jMenuItem11 = new javax.swing.JMenuItem();
		jMenuItem14 = new javax.swing.JMenuItem();
		jMenu3 = new javax.swing.JMenu();
		jMenuItem12 = new javax.swing.JMenuItem();
		jMenuItem13 = new javax.swing.JMenuItem();

		setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
		setTitle("Compta");
		setName("MainWindow");
		addWindowListener(new java.awt.event.WindowAdapter() {
			public void windowClosed(java.awt.event.WindowEvent evt) {
				closeAll(evt);
			}

			public void windowDeactivated(java.awt.event.WindowEvent evt) {
				test(evt);
			}

			public void windowClosing(java.awt.event.WindowEvent evt) {
				closingAll(evt);
			}
		});

		BackgroundPanel.setBackground(new java.awt.Color(141, 178, 227));

		jToolBar1.setBackground(new java.awt.Color(236, 241, 253));
		jToolBar1.setFloatable(false);
		jToolBar1.setRollover(true);

		importButton.setBackground(new java.awt.Color(236, 241, 253));
		importButton
				.setIcon(new javax.swing.ImageIcon(
						"icones/import.png")); // NOI18N
		importButton.setBorder(null);
		importButton.setFocusable(false);
		importButton
				.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
		importButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
		importButton.addMouseListener(new java.awt.event.MouseAdapter() {
			public void mouseClicked(java.awt.event.MouseEvent evt) {
				callExportWindow(evt);
			}
		});
		jToolBar1.add(importButton);

		jButton2.setBackground(new java.awt.Color(236, 241, 253));
		jButton2.setIcon(new javax.swing.ImageIcon(
				"icones/search.png")); // NOI18N
		jButton2.setBorder(null);
		jButton2.setFocusable(false);
		jButton2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
		jButton2.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
		jButton2.addMouseListener(new java.awt.event.MouseAdapter() {
			public void mouseClicked(java.awt.event.MouseEvent evt) {
				searchWindow(evt);
			}
		});
		jButton2.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				jButton2ActionPerformed(evt);
			}
		});
		jToolBar1.add(jButton2);

		jButton3.setBackground(new java.awt.Color(236, 241, 253));
		jButton3.setIcon(new javax.swing.ImageIcon(
				"icones/print.png")); // NOI18N
		jButton3.setBorder(null);
		jButton3.setFocusable(false);
		jButton3.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
		jButton3.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
		jButton3.addMouseListener(new java.awt.event.MouseAdapter() {
			public void mouseClicked(java.awt.event.MouseEvent evt) {
				callPrintEvent(evt);
			}
		});
		jToolBar1.add(jButton3);

		jButton4.setBackground(new java.awt.Color(236, 241, 253));
		jButton4.setIcon(new javax.swing.ImageIcon(
				"icones/statistic.png")); // NOI18N
		jButton4.setBorder(null);
		jButton4.setFocusable(false);
		jButton4.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
		jButton4.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
		jButton4.addMouseListener(new java.awt.event.MouseAdapter() {
			public void mouseClicked(java.awt.event.MouseEvent evt) {
				callChartWindow(evt);
			}
		});
		jToolBar1.add(jButton4);

		jButton5.setBackground(new java.awt.Color(236, 241, 253));
		jButton5.setIcon(new javax.swing.ImageIcon(
				"icones/calc.png")); // NOI18N
		jButton5.setBorder(null);
		jButton5.setFocusable(false);
		jButton5.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
		jButton5.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
		jButton5.addMouseListener(new java.awt.event.MouseAdapter() {
			public void mouseClicked(java.awt.event.MouseEvent evt) {
				callCalcEvent(evt);
			}
		});
		jToolBar1.add(jButton5);

		jButton6.setBackground(new java.awt.Color(236, 241, 253));
		jButton6.setIcon(new javax.swing.ImageIcon(
				"icones/help.png")); // NOI18N
		jButton6.setBorder(null);
		jButton6.setFocusable(false);
		jButton6.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
		jButton6.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
		jButton6.addMouseListener(new java.awt.event.MouseAdapter() {
			public void mouseClicked(java.awt.event.MouseEvent evt) {
				callHelpEvent(evt);
			}
		});
		jToolBar1.add(jButton6);

		jTabbedPane2
				.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

		jEditorPane1.setBackground(new java.awt.Color(236, 242, 251));
		jScrollPane2.setViewportView(jEditorPane1);

		jTabbedPane2.addTab("Notes", jScrollPane2);

		jTabbedPane3.setBorder(javax.swing.BorderFactory
				.createTitledBorder("Balance"));
		jTabbedPane3
				.setTabLayoutPolicy(javax.swing.JTabbedPane.SCROLL_TAB_LAYOUT);
		jTabbedPane3.setName("Balance");

		BankBalancePanel.setBackground(new java.awt.Color(236, 242, 251));

		lightLabel
				.setIcon(new javax.swing.ImageIcon(
						"icones/lighter.png")); // NOI18N

		PreviousBalanceLabel.setText("Previous Balance");

		PreviousBalanceValue.setText("-56,00 \u20ac");

		NewBalanceLabel.setText("New Balance");

		NewBalanceValue.setText("83 890 675,00 \u20ac");

		org.jdesktop.layout.GroupLayout BankBalancePanelLayout = new org.jdesktop.layout.GroupLayout(
				BankBalancePanel);
		BankBalancePanel.setLayout(BankBalancePanelLayout);
		BankBalancePanelLayout
				.setHorizontalGroup(BankBalancePanelLayout
						.createParallelGroup(
								org.jdesktop.layout.GroupLayout.LEADING)
						.add(BankBalancePanelLayout
								.createSequentialGroup()
								.addContainerGap()
								.add(BankBalancePanelLayout
										.createParallelGroup(
												org.jdesktop.layout.GroupLayout.LEADING)
										.add(lightLabel)
										.add(BankBalancePanelLayout
												.createSequentialGroup()
												.add(BankBalancePanelLayout
														.createParallelGroup(
																org.jdesktop.layout.GroupLayout.LEADING)
														.add(PreviousBalanceLabel)
														.add(NewBalanceLabel))
												.add(25, 25, 25)
												.add(BankBalancePanelLayout
														.createParallelGroup(
																org.jdesktop.layout.GroupLayout.TRAILING)
														.add(PreviousBalanceValue)
														.add(NewBalanceValue))))
								.addContainerGap(36, Short.MAX_VALUE)));
		BankBalancePanelLayout
				.setVerticalGroup(BankBalancePanelLayout
						.createParallelGroup(
								org.jdesktop.layout.GroupLayout.LEADING)
						.add(BankBalancePanelLayout
								.createSequentialGroup()
								.addContainerGap()
								.add(lightLabel)
								.add(18, 18, 18)
								.add(BankBalancePanelLayout
										.createParallelGroup(
												org.jdesktop.layout.GroupLayout.BASELINE)
										.add(PreviousBalanceLabel)
										.add(PreviousBalanceValue))
								.add(17, 17, 17)
								.add(BankBalancePanelLayout
										.createParallelGroup(
												org.jdesktop.layout.GroupLayout.BASELINE)
										.add(NewBalanceLabel)
										.add(NewBalanceValue))
								.addContainerGap()));

		jTabbedPane3.addTab("Bank balance", BankBalancePanel);

		ClearedPanel.setBackground(new java.awt.Color(236, 242, 251));

		lightLabel1
				.setIcon(new javax.swing.ImageIcon(
						"icones/lighter.png")); // NOI18N

		PreviousBalanceLabel1.setText("Previous Balance");

		PreviousBalanceValue1.setText("0,00 \u20ac");

		NewBalanceLabel1.setText("New Balance");

		NewBalanceValue1.setText("0,00 \u20ac");

		org.jdesktop.layout.GroupLayout ClearedPanelLayout = new org.jdesktop.layout.GroupLayout(
				ClearedPanel);
		ClearedPanel.setLayout(ClearedPanelLayout);
		ClearedPanelLayout
				.setHorizontalGroup(ClearedPanelLayout
						.createParallelGroup(
								org.jdesktop.layout.GroupLayout.LEADING)
						.add(ClearedPanelLayout
								.createSequentialGroup()
								.addContainerGap()
								.add(ClearedPanelLayout
										.createParallelGroup(
												org.jdesktop.layout.GroupLayout.LEADING)
										.add(ClearedPanelLayout
												.createSequentialGroup()
												.add(ClearedPanelLayout
														.createParallelGroup(
																org.jdesktop.layout.GroupLayout.LEADING)
														.add(PreviousBalanceLabel1)
														.add(NewBalanceLabel1))
												.addPreferredGap(
														org.jdesktop.layout.LayoutStyle.RELATED,
														66, Short.MAX_VALUE)
												.add(ClearedPanelLayout
														.createParallelGroup(
																org.jdesktop.layout.GroupLayout.TRAILING)
														.add(PreviousBalanceValue1)
														.add(NewBalanceValue1))
												.add(68, 68, 68))
										.add(ClearedPanelLayout
												.createSequentialGroup()
												.add(lightLabel1)
												.addContainerGap(158,
														Short.MAX_VALUE)))));
		ClearedPanelLayout
				.setVerticalGroup(ClearedPanelLayout
						.createParallelGroup(
								org.jdesktop.layout.GroupLayout.LEADING)
						.add(ClearedPanelLayout
								.createSequentialGroup()
								.addContainerGap()
								.add(lightLabel1)
								.add(18, 18, 18)
								.add(ClearedPanelLayout
										.createParallelGroup(
												org.jdesktop.layout.GroupLayout.BASELINE)
										.add(PreviousBalanceLabel1)
										.add(PreviousBalanceValue1))
								.add(17, 17, 17)
								.add(ClearedPanelLayout
										.createParallelGroup(
												org.jdesktop.layout.GroupLayout.BASELINE)
										.add(NewBalanceLabel1)
										.add(NewBalanceValue1))
								.addContainerGap()));

		jTabbedPane3.addTab("Cleared", ClearedPanel);

		DetailsPanel.setBackground(new java.awt.Color(236, 242, 251));

		lightLabel2
				.setIcon(new javax.swing.ImageIcon(
						"icones/lighter.png")); // NOI18N

		PreviousBalanceLabel2.setText("All Credit");

		PreviousBalanceValue2.setText("-56,00 \u20ac");

		NewBalanceLabel2.setText("All Debit");

		NewBalanceValue2.setText("83 890 675,00 \u20ac");

		ChartLabel.setForeground(new java.awt.Color(0, 0, 255));
		ChartLabel.setText("More statistic ...");
		ChartLabel.addMouseListener(new java.awt.event.MouseAdapter() {
			public void mouseClicked(java.awt.event.MouseEvent evt) {
				callChartWindow(evt);
			}
		});

		org.jdesktop.layout.GroupLayout DetailsPanelLayout = new org.jdesktop.layout.GroupLayout(
				DetailsPanel);
		DetailsPanel.setLayout(DetailsPanelLayout);
		DetailsPanelLayout
				.setHorizontalGroup(DetailsPanelLayout
						.createParallelGroup(
								org.jdesktop.layout.GroupLayout.LEADING)
						.add(DetailsPanelLayout
								.createSequentialGroup()
								.addContainerGap()
								.add(DetailsPanelLayout
										.createParallelGroup(
												org.jdesktop.layout.GroupLayout.LEADING)
										.add(DetailsPanelLayout
												.createSequentialGroup()
												.add(lightLabel2)
												.add(18, 18, 18)
												.add(ChartLabel))
										.add(DetailsPanelLayout
												.createSequentialGroup()
												.add(DetailsPanelLayout
														.createParallelGroup(
																org.jdesktop.layout.GroupLayout.LEADING)
														.add(PreviousBalanceLabel2)
														.add(NewBalanceLabel2))
												.addPreferredGap(
														org.jdesktop.layout.LayoutStyle.RELATED,
														45, Short.MAX_VALUE)
												.add(DetailsPanelLayout
														.createParallelGroup(
																org.jdesktop.layout.GroupLayout.TRAILING)
														.add(PreviousBalanceValue2)
														.add(NewBalanceValue2))
												.addPreferredGap(
														org.jdesktop.layout.LayoutStyle.RELATED)))
								.addContainerGap(56, Short.MAX_VALUE)));
		DetailsPanelLayout
				.setVerticalGroup(DetailsPanelLayout
						.createParallelGroup(
								org.jdesktop.layout.GroupLayout.LEADING)
						.add(DetailsPanelLayout
								.createSequentialGroup()
								.addContainerGap()
								.add(DetailsPanelLayout
										.createParallelGroup(
												org.jdesktop.layout.GroupLayout.TRAILING)
										.add(lightLabel2).add(ChartLabel))
								.add(18, 18, 18)
								.add(DetailsPanelLayout
										.createParallelGroup(
												org.jdesktop.layout.GroupLayout.BASELINE)
										.add(PreviousBalanceLabel2)
										.add(PreviousBalanceValue2))
								.add(DetailsPanelLayout
										.createParallelGroup(
												org.jdesktop.layout.GroupLayout.LEADING)
										.add(DetailsPanelLayout
												.createSequentialGroup()
												.add(17, 17, 17)
												.add(NewBalanceLabel2))
										.add(DetailsPanelLayout
												.createSequentialGroup()
												.addPreferredGap(
														org.jdesktop.layout.LayoutStyle.UNRELATED)
												.add(NewBalanceValue2)))
								.add(23, 23, 23)));

		jTabbedPane3.addTab("Details", DetailsPanel);

		jTabbedPane1
				.setBorder(javax.swing.BorderFactory.createTitledBorder(""));

		jPanel1.setBackground(new java.awt.Color(236, 242, 251));
		jPanel1.setBorder(javax.swing.BorderFactory
				.createBevelBorder(javax.swing.border.BevelBorder.RAISED));

		jButton7.setIcon(new javax.swing.ImageIcon(
				"icones/add.png")); // NOI18N
		jButton7.setBorder(null);
		jButton7.setFocusable(false);
		jButton7.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
		jButton7.setMaximumSize(new java.awt.Dimension(32, 32));
		jButton7.setMinimumSize(new java.awt.Dimension(32, 32));
		jButton7.setPreferredSize(new java.awt.Dimension(32, 32));
		jButton7.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
		jButton7.addMouseListener(new java.awt.event.MouseAdapter() {
			public void mouseClicked(java.awt.event.MouseEvent evt) {
				callEntryWindow(evt);
			}
		});

		jButton8.setIcon(new javax.swing.ImageIcon(
				"icones/modify.png")); // NOI18N
		jButton8.setBorder(null);
		jButton8.setFocusable(false);
		jButton8.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
		jButton8.setMaximumSize(new java.awt.Dimension(32, 32));
		jButton8.setMinimumSize(new java.awt.Dimension(32, 32));
		jButton8.setPreferredSize(new java.awt.Dimension(32, 32));
		jButton8.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
		jButton8.addMouseListener(new java.awt.event.MouseAdapter() {
			public void mouseClicked(java.awt.event.MouseEvent evt) {
				callEntryWindowsModify(evt);
			}
		});

		jButton9.setIcon(new javax.swing.ImageIcon(
				"icones/trash.png")); // NOI18N
		jButton9.setBorder(null);
		jButton9.setFocusable(false);
		jButton9.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
		jButton9.setMaximumSize(new java.awt.Dimension(32, 32));
		jButton9.setMinimumSize(new java.awt.Dimension(32, 32));
		jButton9.setPreferredSize(new java.awt.Dimension(32, 32));
		jButton9.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
		jButton9.addMouseListener(new java.awt.event.MouseAdapter() {
			public void mouseClicked(java.awt.event.MouseEvent evt) {
				callDeleteEntry(evt);
			}
		});

		jLabel1.setText("Add");

		jLabel2.setText("Modify");

		jLabel3.setText("Delete");

		org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(
				jPanel1);
		jPanel1.setLayout(jPanel1Layout);
		jPanel1Layout
				.setHorizontalGroup(jPanel1Layout
						.createParallelGroup(
								org.jdesktop.layout.GroupLayout.LEADING)
						.add(jPanel1Layout
								.createSequentialGroup()
								.add(20, 20, 20)
								.add(jPanel1Layout
										.createParallelGroup(
												org.jdesktop.layout.GroupLayout.LEADING)
										.add(jPanel1Layout
												.createSequentialGroup()
												.addPreferredGap(
														org.jdesktop.layout.LayoutStyle.RELATED)
												.add(jButton7,
														org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
														org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
														org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
												.addPreferredGap(
														org.jdesktop.layout.LayoutStyle.UNRELATED)
												.add(jLabel1)
												.addPreferredGap(
														org.jdesktop.layout.LayoutStyle.RELATED,
														38, Short.MAX_VALUE)
												.add(jButton8,
														org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
														org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
														org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
												.addPreferredGap(
														org.jdesktop.layout.LayoutStyle.UNRELATED)
												.add(jLabel2).add(46, 46, 46))
										.add(jPanel1Layout
												.createSequentialGroup()
												.add(jButton9,
														org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
														org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
														org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
												.addPreferredGap(
														org.jdesktop.layout.LayoutStyle.UNRELATED)
												.add(jLabel3)
												.addContainerGap(139,
														Short.MAX_VALUE)))));
		jPanel1Layout
				.setVerticalGroup(jPanel1Layout
						.createParallelGroup(
								org.jdesktop.layout.GroupLayout.LEADING)
						.add(jPanel1Layout
								.createSequentialGroup()
								.addContainerGap()
								.add(jPanel1Layout
										.createParallelGroup(
												org.jdesktop.layout.GroupLayout.TRAILING)
										.add(jLabel2)
										.add(jButton8,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
												org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
										.add(jButton7,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
												org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
										.add(jLabel1))
								.addPreferredGap(
										org.jdesktop.layout.LayoutStyle.RELATED,
										20, Short.MAX_VALUE)
								.add(jPanel1Layout
										.createParallelGroup(
												org.jdesktop.layout.GroupLayout.TRAILING)
										.add(jButton9,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
												org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
												org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
										.add(jLabel3)).addContainerGap()));

		jTabbedPane1.addTab("Banking Transaction", jPanel1);

		org.jdesktop.layout.GroupLayout LeftPanelLayout = new org.jdesktop.layout.GroupLayout(
				LeftPanel);
		LeftPanel.setLayout(LeftPanelLayout);
		LeftPanelLayout.setHorizontalGroup(LeftPanelLayout
				.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
				.add(jTabbedPane3,
						org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 257,
						Short.MAX_VALUE)
				.add(jTabbedPane2,
						org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 257,
						Short.MAX_VALUE)
				.add(jTabbedPane1,
						org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 257,
						Short.MAX_VALUE));
		LeftPanelLayout
				.setVerticalGroup(LeftPanelLayout
						.createParallelGroup(
								org.jdesktop.layout.GroupLayout.LEADING)
						.add(LeftPanelLayout
								.createSequentialGroup()
								.addContainerGap()
								.add(jTabbedPane1,
										org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
										157,
										org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
								.addPreferredGap(
										org.jdesktop.layout.LayoutStyle.RELATED)
								.add(jTabbedPane2,
										org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
										175, Short.MAX_VALUE)
								.addPreferredGap(
										org.jdesktop.layout.LayoutStyle.RELATED)
								.add(jTabbedPane3,
										org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
										232,
										org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)));

		leftArrowLabel
				.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		leftArrowLabel
				.setIcon(new javax.swing.ImageIcon(
						"icones/leftArrow.png")); // NOI18N
		leftArrowLabel.addMouseListener(new java.awt.event.MouseAdapter() {
			public void mouseClicked(java.awt.event.MouseEvent evt) {
				CallPreviousMonth(evt);
			}
		});

		monthLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		monthLabel.setText("Mars 2011");
		monthLabel.addMouseListener(new java.awt.event.MouseAdapter() {
			public void mouseClicked(java.awt.event.MouseEvent evt) {
				callCalendarWindow(evt);
			}
		});

		rightArrowLabel
				.setIcon(new javax.swing.ImageIcon(
						"icones/rightArrow.png")); // NOI18N
		rightArrowLabel.addMouseListener(new java.awt.event.MouseAdapter() {
			public void mouseClicked(java.awt.event.MouseEvent evt) {
				CallNextMonth(evt);
			}
		});

		jLabel4.setIcon(new javax.swing.ImageIcon("icones/smallCalendar.png")); // NOI18N
		jLabel4.addMouseListener(new java.awt.event.MouseAdapter() {
			public void mouseClicked(java.awt.event.MouseEvent evt) {
				callCalendarWindow(evt);
			}
		});

		org.jdesktop.layout.GroupLayout DatePanelLayout = new org.jdesktop.layout.GroupLayout(
				DatePanel);
		DatePanel.setLayout(DatePanelLayout);
		DatePanelLayout.setHorizontalGroup(DatePanelLayout.createParallelGroup(
				org.jdesktop.layout.GroupLayout.LEADING).add(
				DatePanelLayout
						.createSequentialGroup()
						.add(jLabel4)
						.add(30, 30, 30)
						.add(leftArrowLabel)
						.add(18, 18, 18)
						.add(monthLabel,
								org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
								126,
								org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
						.addPreferredGap(
								org.jdesktop.layout.LayoutStyle.RELATED)
						.add(rightArrowLabel)
						.addContainerGap(94, Short.MAX_VALUE)));
		DatePanelLayout
				.setVerticalGroup(DatePanelLayout
						.createParallelGroup(
								org.jdesktop.layout.GroupLayout.LEADING)
						.add(DatePanelLayout
								.createSequentialGroup()
								.addContainerGap()
								.add(DatePanelLayout
										.createParallelGroup(
												org.jdesktop.layout.GroupLayout.TRAILING)
										.add(monthLabel).add(rightArrowLabel)
										.add(leftArrowLabel))).add(jLabel4));

		jTable1.setModel(new javax.swing.table.DefaultTableModel(
				new Object[][] { { null, null, null, null },
						{ null, null, null, null }, { null, null, null, null },
						{ null, null, null, null } }, new String[] { "Title 1",
						"Title 2", "Title 3", "Title 4" }));
		jScrollPane1.setViewportView(jTable1);

		org.jdesktop.layout.GroupLayout BackgroundPanelLayout = new org.jdesktop.layout.GroupLayout(
				BackgroundPanel);
		BackgroundPanel.setLayout(BackgroundPanelLayout);
		BackgroundPanelLayout
				.setHorizontalGroup(BackgroundPanelLayout
						.createParallelGroup(
								org.jdesktop.layout.GroupLayout.LEADING)
						.add(jToolBar1,
								org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
								875, Short.MAX_VALUE)
						.add(BackgroundPanelLayout
								.createSequentialGroup()
								.add(LeftPanel,
										org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
										org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
										org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
								.add(18, 18, 18)
								.add(BackgroundPanelLayout
										.createParallelGroup(
												org.jdesktop.layout.GroupLayout.TRAILING)
										.add(org.jdesktop.layout.GroupLayout.LEADING,
												BackgroundPanelLayout
														.createSequentialGroup()
														.add(DatePanel,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
																org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
																org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
														.addContainerGap())
										.add(org.jdesktop.layout.GroupLayout.LEADING,
												jScrollPane1,
												org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
												600, Short.MAX_VALUE))));
		BackgroundPanelLayout
				.setVerticalGroup(BackgroundPanelLayout
						.createParallelGroup(
								org.jdesktop.layout.GroupLayout.LEADING)
						.add(BackgroundPanelLayout
								.createSequentialGroup()
								.add(jToolBar1,
										org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
										60,
										org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
								.addPreferredGap(
										org.jdesktop.layout.LayoutStyle.UNRELATED)
								.add(BackgroundPanelLayout
										.createParallelGroup(
												org.jdesktop.layout.GroupLayout.LEADING)
										.add(BackgroundPanelLayout
												.createSequentialGroup()
												.add(DatePanel,
														org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
														org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
														org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
												.add(18, 18, 18)
												.add(jScrollPane1,
														org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
														510, Short.MAX_VALUE)
												.addContainerGap())
										.add(LeftPanel,
												org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
												org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
												Short.MAX_VALUE))));

		jMenuBar1.setBackground(new java.awt.Color(191, 219, 255));

		jMenu1.setText("File");

		jMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
				java.awt.event.KeyEvent.VK_U,
				java.awt.event.InputEvent.CTRL_MASK));
		jMenuItem1
				.setIcon(new javax.swing.ImageIcon(
						"icones/menuUser.png")); // NOI18N
		jMenuItem1.setText("Change user");
		jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				callChangeUser(evt);
			}
		});
		jMenu1.add(jMenuItem1);

		jMenuItem2.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
				java.awt.event.KeyEvent.VK_I,
				java.awt.event.InputEvent.CTRL_MASK));
		jMenuItem2
				.setIcon(new javax.swing.ImageIcon(
						"icones/menuPassword.png")); // NOI18N
		jMenuItem2.setText("Change password");
		jMenu1.add(jMenuItem2);

		jMenuItem3.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
				java.awt.event.KeyEvent.VK_D,
				java.awt.event.InputEvent.CTRL_MASK));
		jMenuItem3
				.setIcon(new javax.swing.ImageIcon(
						"icones/menuDeleteUser.png")); // NOI18N
		jMenuItem3.setText("Delete user");
		jMenu1.add(jMenuItem3);

		jMenuItem4.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
				java.awt.event.KeyEvent.VK_S,
				java.awt.event.InputEvent.CTRL_MASK));
		jMenuItem4
				.setIcon(new javax.swing.ImageIcon(
						"icones/menuImport.png")); // NOI18N
		jMenuItem4.setText("External Backup");
		jMenu1.add(jMenuItem4);

		jMenuBar1.add(jMenu1);

		jMenu2.setText("Transactions");

		jMenuItem5.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
				java.awt.event.KeyEvent.VK_A,
				java.awt.event.InputEvent.CTRL_MASK));
		jMenuItem5
				.setIcon(new javax.swing.ImageIcon(
						"icones/menuAdd.png")); // NOI18N
		jMenuItem5.setText("Add");
		jMenu2.add(jMenuItem5);

		jMenuItem6.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
				java.awt.event.KeyEvent.VK_M,
				java.awt.event.InputEvent.CTRL_MASK));
		jMenuItem6
				.setIcon(new javax.swing.ImageIcon(
						"icones/menuModify.png")); // NOI18N
		jMenuItem6.setText("Modify");
		jMenu2.add(jMenuItem6);

		jMenuItem7.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
				java.awt.event.KeyEvent.VK_F,
				java.awt.event.InputEvent.CTRL_MASK));
		jMenuItem7
				.setIcon(new javax.swing.ImageIcon(
						"icones/menuTrash.png")); // NOI18N
		jMenuItem7.setText("Delete");
		jMenu2.add(jMenuItem7);

		jMenuBar1.add(jMenu2);

		jMenu5.setText("Print");

		jMenuItem8.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
				java.awt.event.KeyEvent.VK_P,
				java.awt.event.InputEvent.CTRL_MASK));
		jMenuItem8
				.setIcon(new javax.swing.ImageIcon(
						"icones/menuPrint.png")); // NOI18N
		jMenuItem8.setText("Print");
		jMenu5.add(jMenuItem8);

		jMenuBar1.add(jMenu5);

		jMenu6.setText("Search");

		jMenuItem9.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
				java.awt.event.KeyEvent.VK_L,
				java.awt.event.InputEvent.CTRL_MASK));
		jMenuItem9
				.setIcon(new javax.swing.ImageIcon(
						"icones/menuSearch.png")); // NOI18N
		jMenuItem9.setText("Search");
		jMenuItem9.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				callSearchWindow(evt);
			}
		});
		jMenu6.add(jMenuItem9);

		jMenuBar1.add(jMenu6);

		jMenu7.setText("Charts");

		jMenuItem10.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
				java.awt.event.KeyEvent.VK_W,
				java.awt.event.InputEvent.CTRL_MASK));
		jMenuItem10
				.setIcon(new javax.swing.ImageIcon(
						"icones/menuchartBar.png")); // NOI18N
		jMenuItem10.setText("For current month");
		jMenu7.add(jMenuItem10);

		jMenuItem11.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
				java.awt.event.KeyEvent.VK_X,
				java.awt.event.InputEvent.CTRL_MASK));
		jMenuItem11
				.setIcon(new javax.swing.ImageIcon(
						"icones/menuDebit.png")); // NOI18N
		jMenuItem11.setText("Debit chart");
		jMenu7.add(jMenuItem11);

		jMenuItem14.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
				java.awt.event.KeyEvent.VK_C,
				java.awt.event.InputEvent.CTRL_MASK));
		jMenuItem14
				.setIcon(new javax.swing.ImageIcon(
						"icones/menuCredit.png")); // NOI18N
		jMenuItem14.setText("Credit chart");
		jMenu7.add(jMenuItem14);

		jMenuBar1.add(jMenu7);

		jMenu3.setText("?");

		jMenuItem12.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
				java.awt.event.KeyEvent.VK_F1, 0));
		jMenuItem12
				.setIcon(new javax.swing.ImageIcon(
						"icones/menuHelp.png")); // NOI18N
		jMenuItem12.setText("Help");
		jMenu3.add(jMenuItem12);

		jMenuItem13.setAccelerator(javax.swing.KeyStroke.getKeyStroke(
				java.awt.event.KeyEvent.VK_F12, 0));
		jMenuItem13
				.setIcon(new javax.swing.ImageIcon(
						"icones/menuAbout.png")); // NOI18N
		jMenuItem13.setText("About");
		jMenuItem13.setToolTipText("About");
		jMenu3.add(jMenuItem13);

		jMenuBar1.add(jMenu3);

		setJMenuBar(jMenuBar1);

		org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(
				getContentPane());
		getContentPane().setLayout(layout);
		layout.setHorizontalGroup(layout.createParallelGroup(
				org.jdesktop.layout.GroupLayout.LEADING).add(BackgroundPanel,
				org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
				org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));
		layout.setVerticalGroup(layout.createParallelGroup(
				org.jdesktop.layout.GroupLayout.LEADING).add(BackgroundPanel,
				org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
				org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));

		pack();
	}// </editor-fold>
	//GEN-END:initComponents

	private void test(java.awt.event.WindowEvent evt) {
		// TODO add your handling code here:
	}

	private void callSearchWindow(java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
	}

	private void callChangeUser(java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
		System.out.println("callChangeUser");
	}

	private void callCalendarWindow(java.awt.event.MouseEvent evt) {
		// TODO add your handling code here:
		CalendarWindow calendar = new CalendarWindow(this, true);
		calendar.setLocation();
		calendar.setVisible(true);
		
		System.err.println("callCalendarWindow");
	}

	public javax.swing.JPanel getDatePanel() {
		return DatePanel;
	}

	public void setDatePanel(javax.swing.JPanel datePanel) {
		DatePanel = datePanel;
	}

	private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
	}

	private void callHelpEvent(java.awt.event.MouseEvent evt) {
		Desktop d = java.awt.Desktop.getDesktop();
		try {
			d.open(new java.io.File("help.pdf"));
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	private void callCalcEvent(java.awt.event.MouseEvent evt) {
		Process p;
		try {
			p = Runtime.getRuntime().exec("calc.exe");
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	private void callPrintEvent(java.awt.event.MouseEvent evt) {
		//		System.out.println("Print...");
		//
		//		Printable printable = new Printable() {
		//			@Override
		//			public int print(Graphics graphics, PageFormat pageFormat,
		//					int pageIndex) throws PrinterException {
		//				return 0;
		//			}
		//		};
		//		int size = 0;
		//
		//		// Create Print Job
		//		PrinterJob pjob = PrinterJob.getPrinterJob();
		//		PageFormat pf = PrinterJob.getPrinterJob().defaultPage();
		//		pjob.setJobName("Print-Compta");
		//		Book book = new Book();
		//		book.append(printable, pf, size);
		//		pjob.setPageable(book);
		//		try {
		//			pjob.print();
		//		} catch (PrinterException e) {
		//			e.printStackTrace();
		//		}
		//		PrinterJob pjob = PrinterJob.getPrinterJob();
		//		PageFormat pf = pjob.defaultPage();
		//		//pjob.setPrintable(new PrintableClass(), pf);
		//		try {
		//			if (pjob.printDialog()) {
		//				pjob.print();
		//			}
		//		} catch (PrinterException e) {
		//		}
		PrinterJob pjob = PrinterJob.getPrinterJob();
		PageFormat pf = pjob.defaultPage();
		try {
			if (pjob.printDialog()) {
				pjob.print();
			}
		} catch (PrinterException e) {
		}

	}

	private void callExportWindow(java.awt.event.MouseEvent evt) {
		ExportWindow exportWindow = new ExportWindow(this, true);
		exportWindow.setVisible(true);
	}

	private void callDeleteEntry(java.awt.event.MouseEvent evt) {
		int line = jTable1.getSelectedRow();
		if (curEntries == null || line == -1 || line >= curEntries.size()) {
			DialogWindow dw = new DialogWindow(null, true, "Error",
					"No selected line", 1, true);
			dw.setVisible(true);
			return;
		} else {
			DialogWindow dw = new DialogWindow(null, true, "Warning",
					"Do you really want to delete this entry?", 2, false);
			dw.setVisible(true);
			if (dw.getReturnStatus() == DialogWindow.RET_OK) {
				core.deleteEntry(curEntries.get(line));
				refreshTable();
			}
		}
	}

	private void searchWindow(java.awt.event.MouseEvent evt) {
		SearchWindow searchWindow = new SearchWindow(this, true);
		searchWindow.setVisible(true);
	}

	private void CallNextMonth(java.awt.event.MouseEvent evt) {
		date.getNext();
		monthLabel.setText(date.getDate().get(0) + " " + date.getDate().get(1));
		List<UserEntry> l = core.getEntriesFor(date.getMonth(), date.getYear());
		System.out.println(l.size() + " entry for this month");
		initTable(l);
	}

	private void CallPreviousMonth(java.awt.event.MouseEvent evt) {
		date.getPrevious();
		monthLabel.setText(date.getDate().get(0) + " " + date.getDate().get(1));
		List<UserEntry> l = core.getEntriesFor(date.getMonth(), date.getYear());
		System.out.println(l.size() + " entry for this month");
		initTable(l);
	}

	private void callEntryWindowsModify(java.awt.event.MouseEvent evt) {
		int line = jTable1.getSelectedRow();
		if (curEntries == null || line == -1 || line >= curEntries.size()) {
			DialogWindow dw = new DialogWindow(null, true, "Error",
					"No selected line", 1, true);
			dw.setVisible(true);
			return;
		}
		EntryWindow entryWindow = new EntryWindow(this, true);
		entryWindow.setUserEntry(curEntries.get(line));
		entryWindow.getCreateButton().setText("Modify");

		entryWindow.getCreateAndcloseButton().setText("Modify and close");

		entryWindow.setVisible(true);
	}

	private void closingAll(java.awt.event.WindowEvent evt) {
		core.setNote(jEditorPane1.getText());
	}

	private void closeAll(java.awt.event.WindowEvent evt) {
		core.setNote(jEditorPane1.getText());
	}

	private void callEntryWindow(java.awt.event.MouseEvent evt) {
		EntryWindow entryWindow = new EntryWindow(this, true);
		entryWindow.setVisible(true);
	}

	private void callChartWindow(java.awt.event.MouseEvent evt) {
		ChartWindow chartWindow = new ChartWindow(this, true);
		chartWindow.setVisible(true);
	}

	/**
	 * @param args
	 *            the command line arguments
	 */

	public static void Example1() {
		// Set up the frame
		JFrame f = new JFrame();
		f.setTitle("Example1");
		f.setDefaultCloseOperation(EXIT_ON_CLOSE);

		Container contentPane = f.getContentPane();
		contentPane.setLayout(new GridLayout(2, 2, 5, 5));

		JCalendar calendar1 = new JCalendar(true);
		JCalendar calendar2 = new JCalendar(/* JCalendar.DISPLAY_DATE, */false);
		JCalendar calendar3 = new JCalendar(false);
		JCalendar calendar4 = new JCalendar(false);

		JPanel panel1 = new JPanel(new FlowLayout());
		panel1.add(calendar1);
		contentPane.add(panel1);

		JPanel panel2 = new JPanel(new FlowLayout());
		panel2.add(calendar2);
		contentPane.add(panel2);

		JPanel panel3 = new JPanel(new FlowLayout());
		panel3.add(calendar3);
		contentPane.add(panel3);

		JPanel panel4 = new JPanel(new FlowLayout());
		panel4.add(calendar4);
		contentPane.add(panel4);
		f.pack();
		f.setVisible(true);
	}

	public static void main(String args[]) {
		// Example1();
		java.awt.EventQueue.invokeLater(new Runnable() {
			public void run() {
				new PrincipalWindow().setVisible(true);
			}
		});
	}

	//GEN-BEGIN:variables
	// Variables declaration - do not modify
	private javax.swing.JPanel BackgroundPanel;
	private javax.swing.JPanel BankBalancePanel;
	private javax.swing.JLabel ChartLabel;
	private javax.swing.JPanel ClearedPanel;
	private javax.swing.JPanel DatePanel;
	private javax.swing.JPanel DetailsPanel;
	private javax.swing.JPanel LeftPanel;
	private javax.swing.JLabel NewBalanceLabel;
	private javax.swing.JLabel NewBalanceLabel1;
	private javax.swing.JLabel NewBalanceLabel2;
	private javax.swing.JLabel NewBalanceValue;
	private javax.swing.JLabel NewBalanceValue1;
	private javax.swing.JLabel NewBalanceValue2;
	private javax.swing.JLabel PreviousBalanceLabel;
	private javax.swing.JLabel PreviousBalanceLabel1;
	private javax.swing.JLabel PreviousBalanceLabel2;
	private javax.swing.JLabel PreviousBalanceValue;
	private javax.swing.JLabel PreviousBalanceValue1;
	private javax.swing.JLabel PreviousBalanceValue2;
	private javax.swing.JButton importButton;
	private javax.swing.JButton jButton2;
	private javax.swing.JButton jButton3;
	private javax.swing.JButton jButton4;
	private javax.swing.JButton jButton5;
	private javax.swing.JButton jButton6;
	private javax.swing.JButton jButton7;
	private javax.swing.JButton jButton8;
	private javax.swing.JButton jButton9;
	private javax.swing.JEditorPane jEditorPane1;
	private javax.swing.JLabel jLabel1;
	private javax.swing.JLabel jLabel2;
	private javax.swing.JLabel jLabel3;
	private javax.swing.JLabel jLabel4;
	private javax.swing.JMenu jMenu1;
	private javax.swing.JMenu jMenu2;
	private javax.swing.JMenu jMenu3;
	private javax.swing.JMenu jMenu5;
	private javax.swing.JMenu jMenu6;
	private javax.swing.JMenu jMenu7;
	private javax.swing.JMenuBar jMenuBar1;
	private javax.swing.JMenuItem jMenuItem1;
	private javax.swing.JMenuItem jMenuItem10;
	private javax.swing.JMenuItem jMenuItem11;
	private javax.swing.JMenuItem jMenuItem12;
	private javax.swing.JMenuItem jMenuItem13;
	private javax.swing.JMenuItem jMenuItem14;
	private javax.swing.JMenuItem jMenuItem2;
	private javax.swing.JMenuItem jMenuItem3;
	private javax.swing.JMenuItem jMenuItem4;
	private javax.swing.JMenuItem jMenuItem5;
	private javax.swing.JMenuItem jMenuItem6;
	private javax.swing.JMenuItem jMenuItem7;
	private javax.swing.JMenuItem jMenuItem8;
	private javax.swing.JMenuItem jMenuItem9;
	private javax.swing.JPanel jPanel1;
	private javax.swing.JScrollPane jScrollPane1;
	private javax.swing.JScrollPane jScrollPane2;
	private javax.swing.JTabbedPane jTabbedPane1;
	private javax.swing.JTabbedPane jTabbedPane2;
	private javax.swing.JTabbedPane jTabbedPane3;
	private javax.swing.JTable jTable1;
	private javax.swing.JToolBar jToolBar1;
	private javax.swing.JLabel leftArrowLabel;
	private javax.swing.JLabel lightLabel;
	private javax.swing.JLabel lightLabel1;
	private javax.swing.JLabel lightLabel2;
	private javax.swing.JLabel monthLabel;
	private javax.swing.JLabel rightArrowLabel;
	// End of variables declaration//GEN-END:variables

}

class CellRendererGreen extends DefaultTableCellRenderer {
	public Component getTableCellRendererComponent(JTable table, Object value,
			boolean isSelected, boolean hasFocus, int row, int column) {
		Component c = super.getTableCellRendererComponent(table, value,
				isSelected, hasFocus, row, column);
		if (!isSelected)
			c.setBackground(new Color(213, 234, 158));
		return c;
	}
}

class CellRendererRed extends DefaultTableCellRenderer {
	public Component getTableCellRendererComponent(JTable table, Object value,
			boolean isSelected, boolean hasFocus, int row, int column) {
		Component c = super.getTableCellRendererComponent(table, value,
				isSelected, hasFocus, row, column);
		if (!isSelected)
			c.setBackground(new Color(246, 131, 131));		
		return c;
	}
}